package cn.wolfcode.luowowo.article.service.impl;


import cn.wolfcode.luowowo.article.mapper.ScenicCommentMysqlMapper;
import cn.wolfcode.luowowo.article.service.IScenicCommentMysqlService;
import cn.wolfcode.luowowo.article.vo.ScenicCommentVO;
import cn.wolfcode.luowowo.common.domain.ScenicComment;
import cn.wolfcode.luowowo.common.query.ScenicCommentObject;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Service
public class ScenicCommentMysqlServiceImpl implements IScenicCommentMysqlService {

    @Autowired
    private ScenicCommentMysqlMapper scenicCommentMysqlMapper;

    @Override
    public void saveComment(ScenicComment comment) {
        comment.setCreateTime(new Date());
        comment.setThumbupnum(0);
        scenicCommentMysqlMapper.save(comment);
    }

    @Override
    public List<ScenicComment> query(ScenicCommentObject qo) {
       /* List<ScenicComment> list = new ArrayList<>();
        List<Long> ids = scenicCommentMysqlMapper.getAllId(qo.getDetailId());
        for (Long id : ids) {
            ScenicComment sc = scenicCommentMysqlMapper.getOne(id);
            list.add(sc);
        }
        return list.subList(qo.getIndex(),qo.getPageSize());*/
        List<ScenicComment> scenicComments = scenicCommentMysqlMapper.listAll(qo);
        return scenicComments;
    }

    @Override
    public boolean thumbup(Long detailId) {
        int thumbup = scenicCommentMysqlMapper.thumbup(detailId);
        if(thumbup == 1){
            return true ;
        }
        return false;
    }

    @Override
    public int getThumbup(Long detailId) {
        return scenicCommentMysqlMapper.getThumbup(detailId);
    }

    @Override
    public List<ScenicCommentVO> selectRemark(Long id) {
        return scenicCommentMysqlMapper.selectRemark(id);
    }

    @Override
    public int count(Long id) {
        return scenicCommentMysqlMapper.count(id);
    }
}
